#/usr/bin/python

import os, sys
from ivic.core.Config import *

vsequencer_yaml = '/etc/ivic/vsequencer.yaml'
class VSequencerConfig(object):
    
    def __init__(self,configmap = None):
        if configmap == None:
            config_vsequencer_path = project_path(vsequencer_yaml)
            self.config = load(config_vsequencer_path)
        else: self.config = configmap
        
        self.log = self.config['log_file']
        if not os.path.exists(self.log): 
            log = open(self.log,'w')
            log.close()
            
        self.metaFile = self.config['metaFile']
        if not os.path.exists(self.metaFile):
            command = " ".join(['mkdir -p',self.metaFile])
            os.system(command)
        self.releasePath = self.config['releasePath']
        self.rootPath = self.config['rootPath']
        self.url = self.config['url']
        self.ca_cert = self.config['ca_cert']
        self.cert = self.config['cert']

    def config_map(self):
        return self.config
   
    
if __name__ == "__main__":
    
    #make sure add logdir and log File created and chmod 0777
    #just For local test.
    logdir = '/var/log/ivic/'
    log = '/var/log/ivic/config.log'

    sys.path.insert(0, os.getcwd())
    
    from ivic.core.Config import *
    ivic.core.set_rundebug()
        
    #config_vprocess_path = project_path('/etc/ivic/vprocess.yaml')
    #config = load(config_vprocess_path)
    config = VSequencerConfig()
    
    print config.metaFile,config.releasePath,config.log
    print config.url,config.ca_cert,config.cert,config.rootPath